/**
 * User: c3t
 * Date: 13-12-7
 * Time: 上午9:33
 */
define(['lib/XmlHttpRequest','lib/getValueByProp'],function(xhr,getV) {

    window.onload = init;
    function init() {
        var btn = document.getElementById("did");
        btn.onchange=getData;
    }

    function getData() {
        var did = this.value;
      xhr.open("post","../person.do",true);
      xhr.onreadystatechange=function() {
          if(xhr.readyState==4 && xhr.status==200) {
              var xmldoc = xhr.responseXML;

              var nodes = xmldoc.getElementsByTagName("person");
              var node="";
              for(var i =0;i<nodes.length;i++) {
                  node+=getV(nodes[i],"name")+"----"
                        +getV(nodes[i],"age")+"----"
                        +getV(nodes[i],"salary")+"<br />";
              }
              document.getElementById("persons").innerHTML=node;
          }
      }
      xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      xhr.send("did="+did);
    }
});